home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: wells2@ix.netcom.com (wells)
- Newsgroups: comp.lang.c++
- Subject: need help with functions
- Date: Mon, 26 Feb 1996 07:45:23 GMT
- Organization: Netcom
- Message-ID: <4grqta$mcb@ixnews3.ix.netcom.com>
- NNTP-Posting-Host: irv-ca15-23.ix.netcom.com
- X-NETCOM-Date: Mon Feb 26 12:27:22 AM PST 1996
- X-Newsreader: Forte Free Agent 1.0.82
-
-
-
- I am learning c++, I wrote this program and I have a problem with it
- that i cant figure out. I am doin this for my class in college. I am
- using pass by reference in my functions, and i have an error that
- says something like.... "Get_payment is not suffieciently different
- then Get_Payment", or something... I dont understand why.
- The program has that error and 4 other warnings, I am not worried
- about the warnings, they have to do with my pow(x,x) statement being a
- float and not an int. I am just worried about the function error. If
- anyone can help I would greatly appreaciate it. And let me know what I
- am doing wrong...
-
- thanks very much..
- edward
- wells2@ix.netcom.com
-
-
-
-
-
- /////////////////////////////////////////////////////////////////////
- // Edward //
-
-
-
- #include <stdio.h> // Header.h
- #include <iostream.h> // Header.h
- #include <math.h> // Header.h
-
-
-
-
- void Loan_Payment(); // Function Prototype
-
- void Maturity(); // Function Prototype
-
- void Get_Payment(float,float,int,float); // Function Prototype
-
- void Get_Maturity(float,int,float,float,float); // Function Prototype
-
-
-
-
-
- void main(void)
- {
-
-
- int user_selection; // variable to hold the menu selection
-
-
- /// Main Menu ////////////////////////////////////////////
- //
-
- cout << "----------- Main Menu ------------\n"; //
- cout << "\n"; //
- cout << "<1> Loan Payment\n"; // print menu on
- cout << "<2> Maturity\n"; // the screen.
- cout << "\n"; //
- cout << "Enter Your Selection -->"; //
-
-
- cin >> user_selection; // get user
- selection.
-
-
- switch (user_selection)
- {
-
-
- case '1': //
- { // If user selected '1', then
- Loan_Payment(); // go to the funtion "Loan_Payment".
- break; //
- } //
-
-
-
- case '2': //
- { // If user selected '2', then
- Maturity(); // go to the function "Maturity".
- break; //
- } //
-
-
- default: //
- { // If user selected neither one
- cout << "Bad Selection"; // then end the program.
- } //
-
- } // End of switch
-
-
- cout << "End Of Program"; // End the program.
- } // End of Program.
-
-
-
- ////////////////////////////// Functions
- ///////////////////////////////
-
-
- void Loan_Payment(void) // This is the function for figuring loan
- // payments.
-
-
- {
- float loan_amount; // holds the loan amount.
- float interest_rate; // holds the interest rate.
- float payment; // hold the final payment amount.
- int number_of_payments; // holds the number of payments.
-
-
-
- cout << "Enter the full loan amount ->"; // input
- cin >> loan_amount; // data
- // from
- cout << "\nEnter the interest rate ->"; // the
- cin >> interest_rate; // user
- //
- cout << "\nEnter the number of payments ->"; //
- cin >> number_of_payments; //
-
-
-
- Get_Payment(loan_amount,interest_rate, // go calculate payment
- number_of_payments,payment); // in function
- Get_Payment.
-
-
-
- cout << "The Payment is ->"; // Print the answer to
- cout << payment; // the screen.
-
- return;
-
- }
-
-
-
- //////////////////////////////////////////////////////////
-
-
- void Maturity(void)
- {
- float investment_amount; // holds the investment amount.
- float interest_rate; // holds the interest rate.
- float time_in_years; // holds the length in years.
- float times_compounded; // holds the times compounded a year.
- float maturity; // holds the maturity.
-
-
- cout << "\nEnter the investment amount ->"; //
- cin >> investment_amount; //
- //
- cout << "\nEnter the interest rate ->"; // get the input
- cin >> interest_rate; //
- // from the user
- cout << "\nEnter the time in years ->"; //
- cin >> time_in_years; //
- //
- cout << "\nHow many times compounded yearly ->"; //
- cin >> times_compounded; //
-
-
-
- Get_Maturity(investment_amount,time_in_years, // get the
- times_compounded,maturity,interest_rate); // maturity.
-
- cout << "\nThe maturity is ->"; // output to the
- cout << maturity; // screen.
-
- return;
- }
-
-
-
- ///////////////////////////////////////////////////////////
-
-
-
-
- void Get_Payment(float &loan_amount,float &interest_rate,int
- &number_of_payments,
- float &payment)
-
- {
-
- float temp1,temp2,temp3,temp4; // temp variables during math.
-
- interest_rate - interest_rate / 1200; //
- temp1 = (1+interest_rate); // do the math
- temp2 = pow(temp1,number_of_payments)* interest_rate;// for payment.
- temp3 = (1+interest_rate); //
- temp4 = pow(temp3,number_of_payments)-1; //
- payment = ((temp2/temp4)*loan_amount); //
- return;
- }
-
-
-
-
- //////////////////////////////////////////////////////////
-
-
-
-
-
- void Get_Maturity( float &investment_amount,float &time_in_years,
- float ×_compounded,float &maturity,
- float &interest_rate)
-
- {
- float temp1; // temporary for math function.
- float temp2; // temporary for math function.
- float temp3; // temporary for math function.
-
- interest_rate = interest_rate /100; //
- temp1 = ((interest_rate/times_compounded)+1); // Do the math to
- temp2 = (time_in_years * times_compounded); // get the maturity.
- temp3 = pow(temp1,temp2); //
- maturity = (temp3 * investment_amount); //
-
- return;
- }
-
-
- /////////////////////////////////////////////////////
-
-
-
-
-
-
-
-
-